package com.wx.aopservice;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/**
 * 使用aop进行计数统计接口被引用的次数
 */
@Component
@Aspect
public class InterfaceCount {
    private int temp;
//    配置切入点
    @Pointcut("execution(public * com.wx..*.*(..))")
    public void pt(){}

    // 对方法进行增强
    @Before("pt()")
    public void count(JoinPoint pjp){
        String typeName = pjp.getSignature().getDeclaringTypeName();
        temp++;
        System.out.println(typeName+"：被引用"+temp+"次");
    }
}
